home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / SDKs / PCI Driver Development Kit / • Tools / Development / Forth Tokenizer / Tokenizer README < prev   
Encoding:
Text File  |  1996-08-20  |  5.9 KB  |  106 lines  |  [TEXT/ttxt]

  1. October 17, 1995
  2.  
  3. This version of the Tokenizer is using a public domain version of Forth (called ThisForth), that was developed by Wil Baden and modified by Apple.  The SIOW version allows you to tokenize your Open Firmware FCode without requiring MPW or any other license fees.
  4.  
  5. Simply launch the Tokenizer by double-clicking.  It will create an SIOW window, display some version information, then prompt for input.
  6.  
  7. To tokenize a file, type:
  8.  
  9.     tokenize <filename>
  10.  
  11. This will start tokenizing the top-level file.  Within this file, a tokenizer FLOAD command can be used to include other files.  This command looks like:
  12.  
  13.     fload <filename>
  14.  
  15. FLOADs can be nested.
  16.  
  17. The tokenizer builds the FCode image into an internal buffer.  After all the source has been tokenized, the image is saved by using the save-image command as:
  18.  
  19.     save-image <filename>
  20.  
  21. This generates a binary image of the ROM image, which is padded to a multiple of 512 bytes, as required by the PCI standard.
  22.  
  23. Other formats can be output by the tokenizer:
  24.  
  25.   dump-83 <filename>
  26.  
  27. This format is a common one for use by PROM programmers.
  28.  
  29.     dump-85 <filename>
  30.  
  31. This format is an format utilizing only ASCII characters, similar to uuencode.  The format is described in detail in "Portable Document Format Reference Manual", by Adobe, where it is called ASCII base-85 encoding.
  32.  
  33. Use the Quit menu to exit the program.
  34.  
  35. In addition to the standard Open Firmware words, several additional words have
  36. been added to make it easier to produce PCI Expansion ROM images.  These are:
  37.  
  38.     fcode-version2
  39.     fcode-end
  40.     pci-header
  41.     pci-end
  42.     encode-file
  43.  encode-file-reg
  44.  fcode-date
  45.  fcode-time
  46.  
  47. FCODE-VERSION2
  48. A command that generates an FCode header using START1.  This is meant to be paired with FCODE-END.
  49.  
  50. FCODE-END
  51. A command that generates an END0 FCode and completes the information in the FCode header that was generated by FCODE-VERSION2.
  52.  
  53. PCI-HEADER
  54. A macro that generates a PCI header.  PCI-HEADER expects 3 values on the top of the stack when it is invoked: Vendor#, Device# and Class-Code.  These values are used for the corresponding fields in the PCI Data structure that is built by the PCI-HEADER.  The easiest way of including these values is to put them on the stack outside of the tokenization by using TOKENIZER[ and ]TOKENIZER.
  55.  
  56. PCI-END
  57. A macro that completes the PCI header created by PCI-HEADER.  It fills out the image to a multiple of 512 bytes, and sets the image-length field of the PCI header.
  58.  
  59. A complete FCode image will be generated by:
  60.  
  61.     tokenizer[  hex  1234 5678 ABCDEF decimal ]tokenizer
  62.     pci-header                            \ generate proper PCI image header
  63.         fcode-version2        \ generate proper FCode header (within PCI image)
  64.         ...
  65.         ...
  66.         fcode-end            \ terminate normal FCode
  67.     pci-end                        \ complete the PCI image
  68.  
  69. This would generate a PCI Data structure with the Vendor# == 0x1234, Device# == 0x5678 and Class-Code == 0xABCDEF.
  70.  
  71. NOTE:  It is VERY important that your ROM image contain the proper values for Vendor#, Device# and Class-Code.  These values are checked during the process of locating an appropriate FCode image for the device;  if you do not have values matching your device, your FCode will not be recognized!!!!
  72.  
  73. ENCODE-FILE
  74. ENCODE-FILE is used for embedding device drivers, etc. as properties. It will build a prop-encoded-array, similar to that produced by ENCODE-BYTES, except that the data will be taken from the specified file during tokenization.
  75.  
  76. ENCODE-FILE is followed by the filename to be included;  thus, its syntax is:
  77.  
  78.     ENCODE-FILE <filename>
  79.  
  80. Note that since the filename is obtained using Forth's WORD, it must not contain any embedded blanks.  The following example shows how a property would be generated by means of ENCODE-FILE.
  81.  
  82.     encode-file xyz.bin   " xyz-prop" property
  83.  
  84. The property value of " xyz-prop" would be the contents of the original file, byte-for-byte;  the prop-len of the created property is the same as the length of the original file.
  85.  
  86. ENCODE-FILE-REG
  87. ENCODE-FILE-REG is used to embed device drivers, etc. within the FCode ROM image, but without consuming device-tree space.  The data from the specified file is copied into the ROM image after all of the FCode for has been generated; i.e., at PCI-END time.
  88.  
  89. ENCODE-FILE-REG is followd by the filename to be included;  its syntax is:
  90.  
  91.     ENCODE-FILE-REG <filename>
  92.  
  93. The property value produced is that of a "reg" property for PCI;  i.e., it consists of 5 integers (encoded as with ENCODE-INT) that represent the offset within this FCode image of the file's data.  The "reg"'s phys.hi value (i.e., the config-address) will reference the Expansion ROM;  it will always have a h# 30 as the low-order byte.  The phys.lo value will be the offset of the data (within the Expansion ROM) and the size.lo will be the size of the data.
  94.  
  95. Note: the code generated by ENCODE-FILE-REG relies upon the value of the "fcode-rom-offset" property that should be generated by Open Firmware before starting the evaluation of the FCode.
  96.  
  97. Note that to get to the data, you have to add in the value of the "assigned-addresses" property for the Expansion ROM.  I.e., the value of the encoded property is relative to the base address of the Expansion ROM.  The actual address assigned by Open Firmware to the Expansion ROM is not known at the time that the FCode is evaluated.
  98.  
  99. Note: due to a bug in the Expansion Manager code, DO NOT USE the ENCODE-FILE-REG form for MacOS drivers.  However, other drivers should be encoded with this mechanism to reduce device-tree space.
  100.  
  101. FCODE-DATE
  102. FCODE-DATE creates an FCode string constant that contains the date of the tokenization (in MM/DD.YY format).  This string could be used to create a device tree property that can be inspected by run-time drivers, etc. to check when the image was created.
  103.  
  104. FCODE-TIME
  105. FCODE-TIME creates an FCode string constant that contains the time of the tokenization (in HH:MM:SS format).  This string could be used to create a device tree property that can be inspected by run-time drivers, etc. to check when the image was created.
  106.